function requestResult(data){
    if(data){
        return {
            status: 1,
            message: 'success',
            data
        }
    }else{
        return {
            status: 2,
            message: 'error',
            data
        }
    }
}

async function pagingResult (db, page, size){
    let total = await db.countDocuments()
    let data = await db.find().sort({ 'time': -1 }).limit(size).skip((page - 1) * size)
    return {
        total,
        data,
        page
    }
}

module.exports = {
    requestResult,
    pagingResult
}